//
// Created by Administrator on 2016/9/30.
//

#ifndef ZAINGL_MATERIAL_H
#define ZAINGL_MATERIAL_H

#include "ShareHeaders.h"
#include "Light.h"

namespace ZainGL {
    class Material {
    public:
        Material(const GLchar *pathV, const GLchar *pathF,
                 std::unordered_map<std::string, ZainTL::FileDatas> *bufferMap = nullptr);

    private:
        float specular;
        float shininess;
        static GLuint activeShaderLoc;

        GLuint linkShader(GLuint vsID, GLuint fsID);

        GLuint compileShader(GLenum shaderType, const GLchar *shaderSource);

        const GLchar *
        loadShaderSourceFromBuffer(const char *path, std::unordered_map<std::string, ZainTL::FileDatas> *bufferMap);

    public:
        GLuint mShaderLoc;

        virtual void
        update(glm::mat4 viewMat, glm::vec3 viewPos, glm::mat4 projMat, std::vector<Light *> lights, GLfloat d, GLfloat d1);

        void active();

        void setViewMatrix(glm::mat4 &viewMat);

        static void updateMaterials(std::vector<Material *> materials, glm::mat4 viewMat, glm::vec3 viewPos, glm::mat4 projMat,
                                           std::vector<Light *> lights, GLfloat d, GLfloat d1);
    };
}

#endif //ZAINGL_MATERIAL_H
